class Solution
{
public:
    int minFlips(int a, int b, int c)
    {
        int flipCount = 0;
        for (int i = 0; i < 32; ++i)
        {
            int bitA = a & (1 << i);
            int bitB = b & (1 << i);
            int bitC = c & (1 << i);
            if (bitC)
            {
                if (!(bitA | bitB))
                {
                    ++flipCount;
                }
            }
            else
            {
                if (bitA & bitB)
                {
                    flipCount += 2;
                }
                else if (bitA | bitB)
                {
                    ++flipCount;
                }
            }
        }
        return flipCount;
    }
};